﻿bob.ns.setNs('bob.array.extensions.tests', {

    TestExtensions: function () {

        this.test_contains = function () {

            bob.assert.throwsError(function () { bob.array.extensions.contains(1, []); }, '1');

            var arr = [];
            var item = 1;
            bob.assert.isFalse(bob.array.extensions.contains(arr, item), '2');

            arr.push(2);
            bob.assert.isFalse(bob.array.extensions.contains(arr, item), '3');

            arr.push(item);
            bob.assert.isTrue(bob.array.extensions.contains(arr, item), '4');

            arr.splice(arr.length - 1, 1);
            bob.assert.isFalse(bob.array.extensions.contains(arr, item), '3');

        };

        this.test_remove = function () {

            bob.assert.throwsError(function () { bob.array.extensions.remove(null); }, '1');
            bob.assert.throwsError(function () { bob.array.extensions.remove(1, []); }, '2');

            var arr = [];
            var item = 1;

            bob.assert.throwsError(function () { bob.array.extensions.remove(arr, item); }, '3');
            bob.assert.isFalse(bob.array.extensions.remove(arr, item, true), '4');

            arr.push(item);
            bob.assert.isTrue(bob.array.extensions.remove(arr, item), '5');
            bob.assert.equals(0, arr.length, '6');
            bob.assert.throwsError(function () { bob.array.extensions.remove(arr, item); }, '7');
            bob.assert.isFalse(bob.array.extensions.remove(arr, item, true), '8');

        };
    }

});